<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>clanhe.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      REAL             FUNCTION <a name="CLANHE.1"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a>( NORM, UPLO, N, A, LDA, WORK )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK auxiliary routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          NORM, UPLO
      INTEGER            LDA, N
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      REAL               WORK( * )
      COMPLEX            A( LDA, * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CLANHE.19"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a>  returns the value of the one norm,  or the Frobenius norm, or
</span><span class="comment">*</span><span class="comment">  the  infinity norm,  or the  element of  largest absolute value  of a
</span><span class="comment">*</span><span class="comment">  complex hermitian matrix A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Description
</span><span class="comment">*</span><span class="comment">  ===========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CLANHE.26"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a> returns the value
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     <a name="CLANHE.28"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a> = ( max(abs(A(i,j))), NORM = 'M' or 'm'
</span><span class="comment">*</span><span class="comment">              (
</span><span class="comment">*</span><span class="comment">              ( norm1(A),         NORM = '1', 'O' or 'o'
</span><span class="comment">*</span><span class="comment">              (
</span><span class="comment">*</span><span class="comment">              ( normI(A),         NORM = 'I' or 'i'
</span><span class="comment">*</span><span class="comment">              (
</span><span class="comment">*</span><span class="comment">              ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where  norm1  denotes the  one norm of a matrix (maximum column sum),
</span><span class="comment">*</span><span class="comment">  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
</span><span class="comment">*</span><span class="comment">  normF  denotes the  Frobenius norm of a matrix (square root of sum of
</span><span class="comment">*</span><span class="comment">  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  NORM    (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          Specifies the value to be returned in <a name="CLANHE.45"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a> as described
</span><span class="comment">*</span><span class="comment">          above.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  UPLO    (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          Specifies whether the upper or lower triangular part of the
</span><span class="comment">*</span><span class="comment">          hermitian matrix A is to be referenced.
</span><span class="comment">*</span><span class="comment">          = 'U':  Upper triangular part of A is referenced
</span><span class="comment">*</span><span class="comment">          = 'L':  Lower triangular part of A is referenced
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the matrix A.  N &gt;= 0.  When N = 0, <a name="CLANHE.55"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a> is
</span><span class="comment">*</span><span class="comment">          set to zero.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A       (input) COMPLEX array, dimension (LDA,N)
</span><span class="comment">*</span><span class="comment">          The hermitian matrix A.  If UPLO = 'U', the leading n by n
</span><span class="comment">*</span><span class="comment">          upper triangular part of A contains the upper triangular part
</span><span class="comment">*</span><span class="comment">          of the matrix A, and the strictly lower triangular part of A
</span><span class="comment">*</span><span class="comment">          is not referenced.  If UPLO = 'L', the leading n by n lower
</span><span class="comment">*</span><span class="comment">          triangular part of A contains the lower triangular part of
</span><span class="comment">*</span><span class="comment">          the matrix A, and the strictly upper triangular part of A is
</span><span class="comment">*</span><span class="comment">          not referenced. Note that the imaginary parts of the diagonal
</span><span class="comment">*</span><span class="comment">          elements need not be set and are assumed to be zero.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDA     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array A.  LDA &gt;= max(N,1).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace) REAL array, dimension (MAX(1,LWORK)),
</span><span class="comment">*</span><span class="comment">          where LWORK &gt;= N when NORM = 'I' or '1' or 'O'; otherwise,
</span><span class="comment">*</span><span class="comment">          WORK is not referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      REAL               ONE, ZERO
      PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      INTEGER            I, J
      REAL               ABSA, SCALE, SUM, VALUE
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.86"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      EXTERNAL           <a name="LSAME.87"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           <a name="CLASSQ.90"></a><a href="classq.f.html#CLASSQ.1">CLASSQ</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          ABS, MAX, REAL, SQRT
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.0 ) THEN
         VALUE = ZERO
      ELSE IF( <a name="LSAME.99"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( NORM, <span class="string">'M'</span> ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Find max(abs(A(i,j))).
</span><span class="comment">*</span><span class="comment">
</span>         VALUE = ZERO
         IF( <a name="LSAME.104"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> ) ) THEN
            DO 20 J = 1, N
               DO 10 I = 1, J - 1
                  VALUE = MAX( VALUE, ABS( A( I, J ) ) )
   10          CONTINUE
               VALUE = MAX( VALUE, ABS( REAL( A( J, J ) ) ) )
   20       CONTINUE
         ELSE
            DO 40 J = 1, N
               VALUE = MAX( VALUE, ABS( REAL( A( J, J ) ) ) )
               DO 30 I = J + 1, N
                  VALUE = MAX( VALUE, ABS( A( I, J ) ) )
   30          CONTINUE
   40       CONTINUE
         END IF
      ELSE IF( ( <a name="LSAME.119"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( NORM, <span class="string">'I'</span> ) ) .OR. ( <a name="LSAME.119"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( NORM, <span class="string">'O'</span> ) ) .OR.
     $         ( NORM.EQ.<span class="string">'1'</span> ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Find normI(A) ( = norm1(A), since A is hermitian).
</span><span class="comment">*</span><span class="comment">
</span>         VALUE = ZERO
         IF( <a name="LSAME.125"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> ) ) THEN
            DO 60 J = 1, N
               SUM = ZERO
               DO 50 I = 1, J - 1
                  ABSA = ABS( A( I, J ) )
                  SUM = SUM + ABSA
                  WORK( I ) = WORK( I ) + ABSA
   50          CONTINUE
               WORK( J ) = SUM + ABS( REAL( A( J, J ) ) )
   60       CONTINUE
            DO 70 I = 1, N
               VALUE = MAX( VALUE, WORK( I ) )
   70       CONTINUE
         ELSE
            DO 80 I = 1, N
               WORK( I ) = ZERO
   80       CONTINUE
            DO 100 J = 1, N
               SUM = WORK( J ) + ABS( REAL( A( J, J ) ) )
               DO 90 I = J + 1, N
                  ABSA = ABS( A( I, J ) )
                  SUM = SUM + ABSA
                  WORK( I ) = WORK( I ) + ABSA
   90          CONTINUE
               VALUE = MAX( VALUE, SUM )
  100       CONTINUE
         END IF
      ELSE IF( ( <a name="LSAME.152"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( NORM, <span class="string">'F'</span> ) ) .OR. ( <a name="LSAME.152"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( NORM, <span class="string">'E'</span> ) ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Find normF(A).
</span><span class="comment">*</span><span class="comment">
</span>         SCALE = ZERO
         SUM = ONE
         IF( <a name="LSAME.158"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> ) ) THEN
            DO 110 J = 2, N
               CALL <a name="CLASSQ.160"></a><a href="classq.f.html#CLASSQ.1">CLASSQ</a>( J-1, A( 1, J ), 1, SCALE, SUM )
  110       CONTINUE
         ELSE
            DO 120 J = 1, N - 1
               CALL <a name="CLASSQ.164"></a><a href="classq.f.html#CLASSQ.1">CLASSQ</a>( N-J, A( J+1, J ), 1, SCALE, SUM )
  120       CONTINUE
         END IF
         SUM = 2*SUM
         DO 130 I = 1, N
            IF( REAL( A( I, I ) ).NE.ZERO ) THEN
               ABSA = ABS( REAL( A( I, I ) ) )
               IF( SCALE.LT.ABSA ) THEN
                  SUM = ONE + SUM*( SCALE / ABSA )**2
                  SCALE = ABSA
               ELSE
                  SUM = SUM + ( ABSA / SCALE )**2
               END IF
            END IF
  130    CONTINUE
         VALUE = SCALE*SQRT( SUM )
      END IF
<span class="comment">*</span><span class="comment">
</span>      <a name="CLANHE.182"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a> = VALUE
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CLANHE.185"></a><a href="clanhe.f.html#CLANHE.1">CLANHE</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
